﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

using TADF.Com.Alpha.Core.View.Component;

namespace TADF.Com.Alpha.Core.View
{
    public class DataView
    {
        private string page;
        private List<Component.Component> components = new List<Component.Component>();

        public void SetPage(string page)
        {
            this.page = page;
        }

        public string GetPage()
        {
            return page;
        }

        public void AddComponent(Component.Component c)
        {
            components.Add(c);
        }

        public string ToXML()
        {
            StringBuilder sb = new StringBuilder(1024);
            sb.Append("<xml>");
            sb.Append("<dataview>");
            for (int i = 0; i < components.Count; ++i)
            {
                sb.Append(components[i].ToXML());
            }
            sb.Append("</dataview>");
            if (page != null && !page.Trim().Equals(""))
            {
                sb.Append("<page><![CDATA[" + /*WebContext.getPageContent(WebContext.getSessionContext().getRequest(),
                        WebContext.getSessionContext().getResponse(), page)*/
                        "<a href='test.html?UserId=zhanghua'>zhanghua</a> " + "]]></page>");
            }
            sb.Append("</xml>");
            return sb.ToString();
        }
    }
}
